<?php

namespace App\Providers;

use Illuminate\Support\Carbon;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {

    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Carbon::setLocale('zh'); // Carbon格式化后的内容中文显示

        $this->app->alias('api.exception', 'App\Exceptions\ApiHandler');  // 自定义错误处理
        $this->app->singleton('api.exception', function ($app) {
            return new \App\Exceptions\ApiHandler($app['Illuminate\Contracts\Debug\ExceptionHandler'],
                $app['config']['api.errorFormat'], $app['config']['api.debug']);
        });
    }


}
